package controller.cartp;

import com.alibaba.fastjson.JSON;
import com.zuche.framework.tradingPlatform.CurrenceSource;
import com.zuche.framework.tradingPlatform.GroupType;
import com.zuche.framework.tradingPlatform.RequestParams;
import com.zuche.framework.utils.PropertiesReader;
import controller.constant.CarTpConstant;
import controller.enums.GroupTypeEnum;
import controller.remote.CartpRemoteClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

/**银联rpc接口测试类
 * Created by 雷霆 on 2016/10/18.
 */
@Controller
@RequestMapping(value = "weChat/",produces = "text/html;charset=utf-8")
public class WechatTestController {
    private static final Logger logger = LoggerFactory.getLogger(WechatTestController.class);

    private String projectAddress;

    public WechatTestController() {
        this.projectAddress = PropertiesReader.getAppointPropertiesAttribute(
                "setting", "projectAddress", String.class);
    }

    /**
     * 微信支付
     * @param request
     * @param response
     */
    @RequestMapping("/testWechat.do_")
    public void testWechatApp(HttpServletRequest request,
                              HttpServletResponse response) {
        Map<String, String> paramMap = new HashMap<String, String>();
//	      paramMap.put(RequestParams.GROUP_TYPE, GroupType.WECHAT_MOBILE);
        // paramMap.put(RequestParams.GROUP_TYPE, GroupType.WECHAT_UNIFY);
        paramMap.put(RequestParams.UNIFY_TYPE, "APP");
        paramMap.put(RequestParams.GROUP_TYPE, GroupType.WECHAT_MOBILE);
        paramMap.put(RequestParams.ASYNC_REPLY_URL, "http://10.100.21.42:8011/carmapi/m/pay/reletPayReturn.action");
        paramMap.put(RequestParams.BUSINESS_ID, "14795389461181");
        paramMap.put(RequestParams.BUSINESS_MONEY, "1");
        paramMap.put(RequestParams.BUSINESS_NAME, "test");
        paramMap.put(RequestParams.PAYER_ID, "10676342");
        paramMap.put(RequestParams.SYS_GROUP, "0");
        paramMap.put(RequestParams.CUSTOMIZED_FLAG + "selfParam", "liqingyuan");
        logger.error(" [carttp调用参数] : " + JSON.toJSONString(paramMap));
        Map<String,String> resultMap = CartpRemoteClient.doRpcInvoke(paramMap, true);
        logger.error(" [carttp返回结果] : " + JSON.toJSONString(resultMap));    }


}
